<?php
if(LOCALHOST) {
    $ref = isset($_GET['ref']) ? $_GET['ref'] : GLOBAL_URL.substr($_SERVER['PHP_SELF'],1).'?'.$_SERVER['QUERY_STRING'];
} else {
    $ref = isset($_GET['ref']) ? $_GET['ref'] : ADMINER_URL.'index.php'.$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];
}
include_once 'inc_modules_path.php'; ?>
<span>未处理数<?php echo $total?></span>
<div class="boxed">
    <div class="boxed-inner seamless">

<table class="table table-striped table-hover select-list">
    <thead>
        <tr>
            <th class="width-small"><input id='selectbox-all' type="checkbox" > </th>
            <th>用户名</th>
            <th>手机号</th>
            <th>提现金额</th>
            <th>申请方式</th>
            <th>关联第三方账户</th>
            <th>商户订单号</th>
            <th>第三方交易号</th>
            <th>审核状态</th>
            <th>申请时间</th>
            <th>更新时间</th>
            <th>交易完成时间</th>
            <th class="span1">操作</th>
        </tr>
    </thead>
    <tbody class="sort-list">
        <?php foreach ($list as $v):?>
        <tr data-id="<?php echo $v['id'] ?>" data-sort="<?php echo $v['sort_id'] ?>">
            <td><input class="select-it" type="checkbox" value="<?php echo $v['id']; ?>" ></td>
            <td>
                <?php echo $v['uname']?>
            </td>
            <td>
                <?php echo $v['phone']?>
            </td>
            <td> <?php echo $v['money'] ?></td>
            <td> <?php echo $v['type'] == 1 ? '微信' : '支付宝' ?></td>
            <td> <?php echo $v['type'] == 1 ? $v['nickname'] : $v['alipay_num'].'('.$v['alipay_name'].')' ?></td>
            <td> <?php echo $v['partner_trade_no'] ?></td>
            <td> <?php echo $v['trade_sn'] ?></td>
            <!--   0 未审核 1 已审核打款 3 拒绝         -->
            <td> <?php echo $v['is_checked'] == 0 ? '未审核' : ($v['is_checked'] == 1 ? '已审核打款' : '拒绝') ?></td>
            <td> <?php echo  date("Y/m/d H:i:s",$v['created']); ?> </td>
            <td> <?php echo  $v['updated'] ? date("Y/m/d H:i:s",$v['updated']) : ''; ?> </td>
            <td> <?php echo  $v['finished'] ? date("Y/m/d H:i:s",$v['finished']) : ''; ?> </td>
            <td>
                <div class="btn-group">
                    <?php if($v['is_checked'] == 0) {?>
                        <?php if($v['type'] == 1) {?>
                            <a class='btn btn-small agree' data-id="<?php echo $v['id'];?>"> 同意 </a>
                        <?php } else {?>
                            <a class='btn btn-small' href=" <?php echo site_url( $this->router->class.'/Alibatch/'.$this->cid.'?id='.$v['id'].'&is_checked=1'.'&ref='.base64_encode($ref)) ?> " target="_blank" onclick="javascript:return check_one()"> 同意 </a>

                        <?php }?>
                        <!--<a class='btn btn-small' href=" <?php /*echo site_url( $this->router->class.'/one/'.$this->cid.'?id='.$v['id'].'&status=1'.'&ref='.base64_encode($ref)) */?> "> 正在审核 </a>-->
                        <a class='btn btn-small' href=" <?php echo site_url( $this->router->class.'/one/'.$this->cid.'?id='.$v['id'].'&is_checked=3'.'&ref='.base64_encode($ref)) ?> " onclick="javascript:return check_one()"> 拒绝 </a>
                    <?php }?>
                </div>
            </td>
        </tr>
        <?php endforeach;?>
    </tbody>
</table>

    </div>
</div>

<?php echo $pages; ?>

<script>
    function check_one() {
        var msg = "请确认您的操作";
        if (confirm(msg)==true){
            return true;
        }else{
            return false;
        }
    }
require(['adminer/js/ui'],function(ui){
  var withdrawapply = {
    url_del: "<?php echo site_urlc('withdrawapply/delete'); ?>"
    ,url_audit: "<?php echo site_urlc('withdrawapply/audit'); ?>"
    ,url_flag: "<?php echo site_urlc('withdrawapply/flag'); ?>"
//    ,url_sortid: "<?php //echo site_urlc('withdrawapply/sortid'); ?>//"
  };

  ui.fancybox_img();
  ui.btn_delete(withdrawapply.url_del);     // 删除
  ui.btn_audit(withdrawapply.url_audit);    // 审核
  ui.btn_flag(withdrawapply.url_flag);      // 推荐
//  ui.sortable(withdrawapply.url_sortid);    // 排序


    $('.agree').click(function(){
        var apply_id=$(this).data('id');
        url='<?php echo site_url('apply_ajax/withdraw_apply_agree');?>';
        $.ajax({
            url:url,
            type:'post',
            dataType:'json',
            data:{apply_id:apply_id,is_check:1,_cfs:$.cookie('_cfc')}
        })
            .done(function(data){
                if(data.status){
                    $.pnotify({
                        title:"提示！",
                        text:data.msg,
                        type:"success",
                        animation: 'fade'
                    });
                    setTimeout(function(){
                        window.location.reload();
                    }, 2000)
                }else{
                    $.pnotify({
                        title:"提示！",
                        text:data.msg,
                        type:"failed",
                        animation: 'fade'
                    });
                }
            });
    });
});
</script>
